﻿#region
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
#endregion

namespace YTBZ.CSSJS
{
    public partial class TEST : BasePage
    {
        #region pageLoad
        protected void Page_Load(object sender, EventArgs e)
        {
            //pgShow.SetTarget(dgList, new PagerNavigation.BindDataDelegate(pageBind));
            //pgShow.SetStyle(strReqPageCount()); if (IsPostBack && pgShow.CurrPgSpit) { pageBind(); }
            if (!IsPostBack)
            {
                pageInit();
                pageBind();
            }
        }
        #endregion

        #region pageInit
        protected override void pageInit()
        {
            TD_TITLE.InnerHtml = Request["TITLE"].ToString();

            txtQB.Text = strDate();
            txtQE.Text = strDateTime();
            DataTable dtDDL = new DataTable(); dtDDL.Columns.Add("DDLID"); dtDDL.Columns.Add("DDLNAME");
            DataRow drDDL = dtDDL.NewRow();
            drDDL = dtDDL.NewRow(); drDDL["DDLID"] = 1; drDDL["DDLNAME"] = "下拉1"; dtDDL.Rows.Add(drDDL);
            drDDL = dtDDL.NewRow(); drDDL["DDLID"] = 2; drDDL["DDLNAME"] = "下拉2"; dtDDL.Rows.Add(drDDL);
            drDDL = dtDDL.NewRow(); drDDL["DDLID"] = 3; drDDL["DDLNAME"] = "下拉3"; dtDDL.Rows.Add(drDDL);
            drDDL = dtDDL.NewRow(); drDDL["DDLID"] = 4; drDDL["DDLNAME"] = "下拉4"; dtDDL.Rows.Add(drDDL);
            drDDL = dtDDL.NewRow(); drDDL["DDLID"] = 5; drDDL["DDLNAME"] = "下拉5"; dtDDL.Rows.Add(drDDL);
            DDLBind(dtDDL, "DDLID", "DDLNAME", true, ref ddlQ);
            DDLBind(dtDDL, "DDLID", "DDLNAME", false, ref ddlE);
            DDLBindState(true, ref ddlQSTATE);
        }
        protected void ddlE_OnSelectedIndexChanged(object sender, EventArgs e)
        {
            if (ddlE.SelectedValue == "") { return; }
            DataTable dtDDL = new DataTable(); dtDDL.Columns.Add("DDLID"); dtDDL.Columns.Add("DDLNAME");
            DataRow drDDL = dtDDL.NewRow();
            drDDL = dtDDL.NewRow(); drDDL["DDLID"] = 1; drDDL["DDLNAME"] = ddlE.SelectedItem.Text + "下拉1"; dtDDL.Rows.Add(drDDL);
            drDDL = dtDDL.NewRow(); drDDL["DDLID"] = 2; drDDL["DDLNAME"] = ddlE.SelectedItem.Text + "下拉2"; dtDDL.Rows.Add(drDDL);
            drDDL = dtDDL.NewRow(); drDDL["DDLID"] = 3; drDDL["DDLNAME"] = ddlE.SelectedItem.Text + "下拉3"; dtDDL.Rows.Add(drDDL);

            DDLBind(dtDDL, "DDLNAME", "DDLID", true, ref ddlEE);
        }
        #endregion

        #region pageBind
        protected override void pageBind()
        {
            DataTable dt = new DataTable();
            dt.Columns.Add("KEYID"); dt.Columns.Add("TTCODE"); dt.Columns.Add("TTNAME"); dt.Columns.Add("TTDATE");
            dt.Columns.Add("TTINFO"); dt.Columns.Add("TTMORE"); DataRow dr = dt.NewRow();
            for (int i = 1; i < 10; i++)
            {
                dr = dt.NewRow();
                dr["KEYID"] = "TT" + i.ToString();
                dr["TTCODE"] = "XX编号00" + i.ToString();
                dr["TTNAME"] = "XX名称" + i.ToString();
                dr["TTDATE"] = DateTime.Now;
                dr["TTINFO"] = "信息信息信息信息信息" + i.ToString();
                dr["TTMORE"] = "爱上对方加拉斯地方啦是的放假啦是的法律手段杰弗里斯的风景奥斯卡地方" + i.ToString();
                dt.Rows.Add(dr);
            }
            DataView dv = dt.DefaultView;
            if (ViewState["SortExpression"] != null) { dv.Sort = GetSortDirectiont(ViewState["SortExpression"].ToString(), ViewState["SortDirection"].ToString()); }
            dgList.DataSource = dv;
            dgList.DataBind(); return;

            SortedList SDList = new SortedList();
            SDList["V_XX"] = "XXX";
            SDList["V_XX"] = "XXXX";
            DataTable dtXXX = proGetDT(SDList,"XXXX");
             
            tabShow.Visible = true;
            tabEdit.Visible = false;
            //pgShow.proDataBind(dt.Rows.Count, SDList, strCurrProcQueryName);

            foreach (GridViewRow gr in dgList.Rows)
            {
                 
                CheckBox objChk = ((CheckBox)(gr.FindControl("chkGet")));

            }
        }
        #endregion 

        #region pageOpt 
        protected override void dgListDo(string strCommandName, string strCommandArgument)
        {
            #region 添加
            if (strCommandName == "添加")
            {
                txtEINPUT1.Text = "";
                txtEINPUT2.Text = "";
                txtEINPUT3.Text = "";
                txtEINPUT4.Text = "";
                btnSave.CommandArgument = "";
                tabEdit.Visible = true;
                tabShow.Visible = false;
            }
            #endregion

            #region 修改
            if (strCommandName == "修改")
            {
                btnSave.CommandArgument = strCommandArgument;
                tabEdit.Visible = true;
                tabShow.Visible = false;
            }
            if (strCommandName == "修改XX")
            {
                SortedList SDList = new SortedList();
                SDList["V_KEYID"] = strCommandArgument;
                DataTable dt = proGetDT(SDList, "XXXX");
                lblUpdate.Text = "";
                if (dt != null && dt.Rows.Count > 0)
                {
                    DataRow dr = dt.Rows[0];
                    //DDLBindValue(dr["BASETYPENAME"].ToString(), ref ddlEBASECLASS);
                    //ddlEBASECLASS_OnSelectedIndexChanged(null, null); 

                    //txtELINKADDR.Text = dr["LINKADDR"].ToString(); 
                    //txtEEXPERTSDESC.Text = dr["EXPERTSDESC"].ToString();
                    //DDLBindValue(dr["STATE"].ToString(), ref ddlESTATE);
                    //txtELINKADDR.Text = strDateTime(dr["LINKADDR"].ToString());

                    lblUpdate.Text = "上次编辑："
                                   + (dr["CREATETIME"].ToString() == "" ? "" : Convert.ToDateTime(dr["CREATETIME"]).ToString("yyyy-MM-dd HH:mm:ss"))
                                   + dr["CREATEMANNAME"].ToString();
                    btnSave.CommandArgument = strCommandArgument;
                    tabEdit.Visible = true;
                    tabShow.Visible = false;
                }
                else
                {
                    jsMessage("参数有误，未找到对应记录！");
                }
            }
            #endregion

            #region 保存
            if (strCommandName == "保存")
            {
                SortedList SDList = new SortedList();
                //SDList["V_PERSONNAME"] = txtEPERSONNAME.Text.Split(' ')[0];
                //SDList["V_STATE"] = ddlESTATE.SelectedValue;

                //SDList["V_KEYID"] = strCommandArgument;
                //SDList["V_OPTUSERID"] = CURRUSERID;
                //SDList["V_OPTUSERNAME"] = CURRUSERNAME;
                string strBack = proSetDT(SDList, "XXXX");
                if (strBack.Substring(0, 2) != "OK")
                {
                    jsMessage(strBack);
                }
                else
                {
                    dgListBaseDo("关闭", "");
                }
            }
            #endregion 

            #region 其他
            if (strCommandName == "其他")
            {
                //XXXX
                pageBind();
            }
            #endregion
        }
        #endregion
    }
}